package com.company02;

import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;



/**
 * Created by admin on 2020/12/26.
 */
public class AlertWindow {
    public  static boolean ansver;


    public static  boolean display(String title,String mg){

        Stage stage=new Stage();
        stage.initModality(Modality.APPLICATION_MODAL);

        //控件
        Label label=new Label();
        label.setText(mg);

        Button button=new Button("是");
        button.setOnMouseClicked(event -> {
            ansver=true;
            stage.close();
        });

        Button buttonNo=new Button("否");
        buttonNo.setOnMouseClicked(event -> {
            ansver=false;
            stage.close();
        });

        VBox vBox=new VBox();

        vBox.getChildren().addAll(label,button,buttonNo);
        vBox.setAlignment(Pos.CENTER);  //按钮居中

        Scene scene=new Scene(vBox,300,300);

        //设置标题
        stage.setTitle(title);
        stage.setScene(scene);
        stage.showAndWait();

        return  ansver;
    }
}
